﻿using System.Diagnostics.CodeAnalysis;
using Microsoft.Practices.Unity;
using TrackIT.Common.Configuration;
using TrackIT.Common.Factories;
using TrackIT.Common.Providers;
using TrackIT.Common.Repositories;
using TrackIT.Common.ViewModel;

namespace TrackIT.Common
{
    [ExcludeFromCodeCoverage]
    public class TrackITInitialiser
    {
        private static bool _initialised = false;

        public static void Initialise()
        {
            if (!_initialised)
            {
                TrackITConfigurationSection config = TrackITConfigurationSection.GetSection();

                TrackITContainer.Current
                   .RegisterType<TrackITSettings, TrackITSettings>()
                   .RegisterInstance(typeof(TrackITBaseConfigurationSection), config)
                   .RegisterType<IWorkStreamFactory, WorkStreamFactory>()
                   .RegisterType<IFileAccessRepository, FileAccessRepository>()
                   .RegisterType<IWorkLogRepository, WorkLogRepository>()
                   .RegisterType<IDateTimeProvider, DateTimeProvider>()
                   .RegisterType<IEmailProvider, EmailProvider>()
                   .RegisterType<TaskViewModel, TaskViewModel>()
                   .RegisterType<ReportViewModel, ReportViewModel>();

                _initialised = true;
            }
        }
    }
}